import F from '../tinycolor/index.js';
const E = new Array(10).fill(0),
  A = {
    red: '#F53F3F',
    orangered: '#FF702E',
    orange: '#FFA500',
    gold: '#FFBD14',
    yellow: '#FFE014',
    lime: '#A1E619',
    green: '#00B82B',
    cyan: '#0BD0D0',
    blue: '#2E8FFF',
    pqbblue: '#1A5EFF',
    purple: '#7126D9',
    magenta: '#FF299F',
  },
  b = {
    light: [
      '#F7F8F9',
      '#F2F3F4',
      '#E5E6E7',
      '#C9CACB',
      '#A9ABAC',
      '#868788',
      '#6B6C6D',
      '#4D4E4F',
      '#28292A',
      '#1E1F20',
    ],
    dark: [
      '#121213',
      '#1C1C1D',
      '#404142',
      '#5E5F60',
      '#797A7B',
      '#9C9E9F',
      '#BCBDBE',
      '#D8D9DB',
      '#E4E6E8',
      '#E8EBEE',
    ],
    primary: '#6B6C6D',
  },
  M = Object.fromEntries(
    Object.entries(A)
      .map(([e, t], r, a) => [
        e,
        {
          light: C({ color: t }),
          dark: d({ color: t }),
          primary: t,
        },
      ])
      .concat([['gray', b]]),
  );
function h(e = {}) {
  const t = E.length / 2 + 1,
    r = e.level ?? t;
  let a = F(e.color);
  const i = a.toHsv(),
    g = i.h,
    n = i.s,
    o = i.v,
    u = g === 0 && n === 0,
    B = r < t,
    l = Math.abs(t - r),
    p = 1,
    f = 0.1;
  let s = n;
  s > f &&
    (B ? (s = n - ((n - f) / (t - 1)) * l) : (s = n + ((p - n) / (t - 1)) * l)),
    u && (s = n);
  const y = u ? 0.97 : 1,
    D = 0.1;
  let c = o;
  return (
    c > D &&
      (B
        ? (c = o + ((y - o) / (t - 1)) * l)
        : (c = o - ((o - D) / (t - 1)) * l)),
    (a = F({
      h: g,
      s,
      v: c,
    })),
    a
  );
}
function v(e = {}) {
  return h(e);
}
function m(e = {}) {
  return h(e).darken(10);
}
function C(e = {}) {
  return E.map((t, r) => v({ ...e, level: r + 1 }));
}
function d(e = {}) {
  return E.map((t, r) => m({ ...e, level: r + 1 })).reverse();
}
function w(e) {
  return F(e).toRgbArray().join(',');
}
export {
  M as colorPresets,
  A as colors,
  C as generate,
  d as generateDark,
  w as getRgbArrayString,
  b as grayPresets,
  v as palette,
  m as paletteDark,
};
